/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef PL_C_TYPE_FLAGS_H
#define PL_C_TYPE_FLAGS_H

#define __dj_ISALNUM 	0x0001
#define __dj_ISALPHA		0x0002
#define __dj_ISCNTRL		0x0004
#define __dj_ISDIGIT		0x0008
#define __dj_ISGRAPH		0x0010
#define __dj_ISLOWER		0x0020
#define __dj_ISPRINT		0x0040
#define __dj_ISPUNCT		0x0080
#define __dj_ISSPACE		0x0100
#define __dj_ISUPPER		0x0200
#define __dj_ISXDIGIT	0x0400

extern unsigned short __dj_ctype_flags[];
extern unsigned char __dj_ctype_toupper[];
extern unsigned char __dj_ctype_tolower[];

#define isalnum(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISALNUM)
#define isalpha(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISALPHA)
#define iscntrl(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISCNTRL)
#define isdigit(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISDIGIT)
#define isgraph(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISGRAPH)
#define islower(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISLOWER)
#define isprint(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISPRINT)
#define ispunct(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISPUNCT)
#define isspace(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISSPACE)
#define isupper(c)  (__dj_ctype_flags[(int)(c)+1] & __dj_ISUPPER)
#define isxdigit(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISXDIGIT)
#define isascii(c)  (!((c)&(~0x7f)))
#define toascii(c)  ((c)&0x7f)

#define tolower(c) (__dj_ctype_tolower[(int)(c)+1])
#define toupper(c) (__dj_ctype_toupper[(int)(c)+1])

#endif
